"""
演示基本的数据类型
"""

import sys

# 整数型,变量不需要声明，直接使用
print("\n---------以下是整数型的演示------\n")
a = 10
b = 20
c = 30000000000000000000000000000000000000000000000
max = sys.maxsize

print("a=" + str(a))
print("b=" + str(b))
print("c=" + str(c) + ",C的数据类型是：" + str(type(c)))
print("Python中int类型的最大值为：" + str(max) + ",Max的数据类型是：" + str(type(max)))

# 浮点数
print("\n---------以下是浮点型的演示------\n")
a = 10.11
b = a / 2
print("浮点数a=" + str(a) + ",数据类型是：" + str(type(a)))
print("浮点数与整数运算的结果是：" + str(type(b)))

# 乘方运算
print("\n---------以下是乘方运算的演示------\n")
a = 2
b = 3
c = a ** b
print("a ** b = " + str(c))

# 字符串类型
print("\n---------以下是字符串的演示------\n")
name = 'AntDream'
message = "Hello " + name + ", would you like to learn Python"
hello = "Hello,What's you name ?"
url = '''http://www.baidu.com
百度一下，你就知道'''  # 多行字符串
url2 = "http://www.baidu.com" \
       "百度一下，你就知道"
print("url = " + url)
print("url2 = " + url2)
print(message)
print(hello)
print(message.title())

'''
字符串访问
'''
hello = "Hello,World!"
a = hello[2]
print("a的数据类型为：", type(a), "，a=", a)
b = hello[-5]
print("b的数据类型为：", type(b), "，b=", b)
c = hello[5]
print("c的数据类型为：", type(c), "，c=", c)


# 格式化字符串
s = "尊敬的{}，您投资的项目{}已经回款"
fmtStr = s.format("张三", 2222)

s2 = "尊敬的%s，您投资的项目%d已经回款"
fmtStr2 = s2 % ("张三", 3333)

print(fmtStr)
print(fmtStr2)
